// Copyright 2022 a.o.smith ALL Rights Reserved
package com.liuxinlong.modules.dao.impl;

import com.liuxinlong.modules.assets.dto.AssetsStatisticsDto;
import com.liuxinlong.modules.dao.AssetsStatisticsDao;
import com.liuxinlong.modules.entity.AssetsStatistics;
import com.liuxinlong.modules.mapper.AssetsStatisticsMapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * AssetsStatisticsInfoDaoImpl
 *
 * @author liuxinlong@hotwater.com.cn
 * @version 1.0.0
 * @since 2023年12月18日
 */
@Service
public class AssetsStatisticsDaoImpl extends ServiceImpl<AssetsStatisticsMapper, AssetsStatistics> implements AssetsStatisticsDao {

    @Override
    public List<AssetsStatistics> pageAssetsStatisticsInfo(Map<String, Object> queryParam) {
        return baseMapper.pageAssetsStatisticsInfo(queryParam);
    }

    @Override
    public int getAssetsStatisticsInfoCount(Map<String, Object> queryParam) {
        return baseMapper.getAssetsStatisticsInfoCount(queryParam);
    }

    @Override
    public AssetsStatistics getAssetsStatisticsInfoByNo(String planNo) {
        return baseMapper.getAssetsStatisticsInfoByNo(planNo);
    }

    @Override
    public Map<String, Map<String, String>> getAssetsStatisticsMap() {
        return baseMapper.getAssetsStatisticsMap();
    }

    @Override
    public AssetsStatistics getStatisticsByAssets(String assetsId, String year) {
        return baseMapper.getStatisticsByAssets(assetsId, year);
    }

    @Override
    public List<AssetsStatisticsDto> getStatisticsList(Map<String, Object> queryParam) {
        return baseMapper.getStatisticsList(queryParam);
    }

    @Override
    public void batchUpdateActualAmount(List<AssetsStatistics> updateList) {
        baseMapper.batchUpdateActualAmount(updateList);
    }

    @Override
    public Map<String, AssetsStatistics> getAllAssetsStatisticsMap() {
        Map<String,Object> queryParam = new HashMap<>();
        queryParam.put("startNum",0);
        queryParam.put("pageSize",100000);
        List<AssetsStatistics> statisticsList = baseMapper.pageAssetsStatisticsInfo(queryParam);
        Map<String,AssetsStatistics> dataMap = new HashMap<>(statisticsList.size());
        for (AssetsStatistics statistics : statisticsList) {
            String sk = statistics.getAssetsId() + "-" + statistics.getCurrentYear();
            dataMap.put(sk,statistics);
        }
        return dataMap;
    }

}
